$OpenBSD: patch-lib_CMakeLists_txt,v 1.11 2015/07/23 08:06:28 jasper Exp $

- From f11bebbdfbe0ebfef9f1bfd7931bdc40511db871 Mon Sep 17 00:00:00 2001
  From: Jasper Lievisse Adriaanse <jasper@humppa.nl>
  Date: Sat, 27 Jun 2015 09:57:48 +0200
  Subject: [PATCH] (maint) Don't attempt to link with libdl on OpenBSD.
- From da47706518e493f9a165f15e0ed9ac5d7a19ab27 Mon Sep 17 00:00:00 2001
  From: Jasper Lievisse Adriaanse <jasper@humppa.nl>
  Date: Thu, 16 Jul 2015 10:42:47 -0600
  Subject: [PATCH] (FACT-1130) Allow specifying the location to install facter.rb to
- Enable basic set of facts

--- lib/CMakeLists.txt.orig	Tue Jul 21 11:31:28 2015
+++ lib/CMakeLists.txt	Thu Jul 23 01:25:11 2015
@@ -115,7 +115,11 @@ if (UNIX)
         set(LIBFACTER_STANDARD_SOURCES ${LIBFACTER_STANDARD_SOURCES} "src/util/posix/scoped_bio.cc")
     endif()
 
-    set(POSIX_LIBRARIES pthread dl)
+    if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
+        set(POSIX_LIBRARIES pthread)
+    else()
+        set(POSIX_LIBRARIES pthread dl)
+    endif()
 endif()
 
 if (WIN32)
@@ -208,6 +212,20 @@ elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")
         "src/facts/bsd/uptime_resolver.cc"
         "src/util/bsd/scoped_ifaddrs.cc"
     )
+elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD")
+    set(LIBFACTER_PLATFORM_SOURCES
+        "src/facts/openbsd/collection.cc"
+        "src/facts/glib/load_average_resolver.cc"
+        "src/facts/bsd/filesystem_resolver.cc"
+        "src/facts/bsd/uptime_resolver.cc"
+        "src/facts/bsd/networking_resolver.cc"
+        "src/facts/openbsd/networking_resolver.cc"
+        "src/util/bsd/scoped_ifaddrs.cc"
+        "src/facts/openbsd/processor_resolver.cc"
+        "src/facts/openbsd/memory_resolver.cc"
+        "src/facts/openbsd/dmi_resolver.cc"
+        "src/facts/openbsd/virtualization_resolver.cc"
+    )
 elseif ("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
     set(LIBFACTER_PLATFORM_SOURCES
         "src/facts/windows/dmi_resolver.cc"
@@ -330,8 +348,13 @@ if (RUBY_FOUND)
         install(CODE "EXECUTE_PROCESS(COMMAND ln -sf libfacter.so libfacter.bundle WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${LIBFACTER_INSTALL_DESTINATION})")
     endif()
 
-    execute_process(COMMAND ${RUBY_EXECUTABLE} -rrbconfig -e "puts RbConfig::CONFIG['vendordir']" OUTPUT_VARIABLE RUBY_VENDORDIR_OUT)
-    string(STRIP ${RUBY_VENDORDIR_OUT} RUBY_VENDORDIR)
+    set(RUBY_LIB_INSTALL "" CACHE PATH "Specify the location to install facter.rb")
+    if(RUBY_LIB_INSTALL)
+      set(RUBY_VENDORDIR ${RUBY_LIB_INSTALL})
+    else()
+      execute_process(COMMAND ${RUBY_EXECUTABLE} -rrbconfig -e "puts RbConfig::CONFIG['vendordir']" OUTPUT_VARIABLE RUBY_VENDORDIR_OUT)
+      string(STRIP ${RUBY_VENDORDIR_OUT} RUBY_VENDORDIR)
+    endif()
     message(STATUS "\"make install\" will install facter.rb to ${RUBY_VENDORDIR}")
     install(FILES ${CMAKE_BINARY_DIR}/lib/facter.rb DESTINATION ${RUBY_VENDORDIR})
 
